import Vue from 'vue'
import Router from 'vue-router'

import iView from 'iview';
import store from '../store/index'
Vue.use(iView);
Vue.use(Router)

// Index
import Index from '@/views/index/Index'
// School
import School from '@/views/index/School'
// Consult
import Consult from '@/views/index/Consult'

/* Sub */
// Article
import Article from '@/views/sub/Article'
import Evaluation from '@/views/sub/Evaluation'
// 
import Help from '@/views/sub/Help'

//顾问中心
import MangeAgent from '@/views/mangeAgent/Mange'
import LoginOrRegAgent from '@/views/mangeAgent/agent/LoginOrReg' //顾问登陆
import Agent from '@/views/mangeAgent/agent/Agent' //顾问个人中心主页
import Demand from '@/views/mangeAgent/agent/Demand' //顾问 接单中心
import OrderHistory from '@/views/mangeAgent/agent/OrderHistory' //顾问 接单历史
import Myteam from '@/views/mangeAgent/agent/Myteam' //顾问 我的团队
import Crm from '@/views/mangeAgent/agent/Crm' //顾问 客户管理
import Userinfo from '@/views/mangeAgent/agent/Userinfo' //顾问 个人信息
import Money from '@/views/mangeAgent/agent/Money' //顾问 充值缴费

//团队中心
import MangeTeam from '@/views/mangeTeam/Mange'
import LoginOrRegTeam from '@/views/mangeTeam/team/LoginOrReg' //团队登陆
import Team from '@/views/mangeTeam/team/Team' //团队个人中心主页
import Statistics from '@/views/mangeTeam/team/Statistics' //团队 业务统计
import Members from '@/views/mangeTeam/team/Members' //团队 成员管理
import TeamManage from '@/views/mangeTeam/team/TeamManage' //团队 团队管理
import TeamUserinfo from '@/views/mangeTeam/team/Userinfo' //顾问 个人信息

const router = new Router({
    mode: 'history',
    // base: '/',
    routes: [{
            path: '/',
            name: 'Index',
            component: Index
        },
        {
            path: '/school',
            name: 'School',
            component: School
        },
        {
            path: '/consult',
            name: 'Consult',
            component: Consult
        },
        {
            path: '/article/:id',
            name: 'Article',
            component: Article
        },
        {
            path: '/Evaluation',
            name: 'Evaluation',
            component: Evaluation
        },
        {
            path: '/Help',
            name: 'Help',
            component: Help
        },
        // 顾问中心
        {
            path: '/mangeAgent',
            // name: 'Mange',
            component: MangeAgent,
            children: [{
                path: '',
                // name:'Agent',
                component: Agent,
                children: [{
                        path: '',
                        name: 'Demand',
                        component: Demand
                    },
                    {
                        path: 'orderHistory',
                        name: 'OrderHistory',
                        component: OrderHistory
                    },
                    {
                        path: 'myteam',
                        name: 'Myteam',
                        component: Myteam
                    },
                    {
                        path: 'crm',
                        name: 'Crm',
                        component: Crm
                    },
                    {
                        path: 'userinfo',
                        name: 'Userinfo',
                        component: Userinfo
                    },
                    {
                        path: 'money',
                        name: 'Money',
                        component: Money
                    }
                ]
            }]
        },
        // 团队中心
        {
            path: '/mangeTeam',
            // name: 'Mange',
            component: MangeTeam,
            children: [{
                path: '',
                // name:'Team',
                component: Team,
                children: [{
                        path: '',
                        name: 'Statistics',
                        component: Statistics,
                    },
                    {
                        path: 'members',
                        name: 'Members',
                        component: Members
                    },
                    {
                        path: 'teamManage',
                        name: 'TeamManage',
                        component: TeamManage
                    },
                    {
                        path: 'teamUserinfo',
                        name: 'TeamUserinfo',
                        component: TeamUserinfo
                    }
                ]
            }]
        }
    ],
    scrollBehavior(to, from, savePosition) {
        if (savePosition) {
            return savePosition
        } else {
            return { x: 0, y: 0 }
        }
    }
})
export default router
// console.log(store.state);
router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    next();
});

router.afterEach(route => {
    iView.LoadingBar.finish();
});